<!DOCTYPE html>
<html class="um landscape min-width-240px min-width-320px min-width-480px 

min-width-768px min-width-1024px">
<head>
  <title></title>
  <meta charset="utf-8">
  <meta name="viewport" content="target-densitydpi=device-dpi, width=device-width, initial-scale=1, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
  <link rel="stylesheet" href="css/fonts/font-awesome.min.css">
  <link rel="stylesheet" href="css/ui-box.css">
  <link rel="stylesheet" href="css/ui-base.css">
  <link rel="stylesheet" href="css/ui-color.css">
  <link rel="stylesheet" href="css/appcan.icon.css">
  <link rel="stylesheet" href="css/appcan.control.css">
  <link rel="stylesheet" href="css/base.css">
</head>
<style type="text/css">
  .cwhite{
    color: white;
  }
 /*  .myfooter{
    margin-top:2em;
  }*/
  /*#tab{
    box-shadow:0px 2px 2px 3px #f5f5f5 inset;
    width: 100%;
    height: 2.5em;
    margin: 0 auto;
    margin-top: .5em;
  /*  border-radius: .4em;*/
    overflow: hidden;
  }*/
  .tabItem:nth-of-type(1) {
    border-top:2px solid orange;
    color:orange;
  }
  .back{
    background-image: url("./images/back.png");
    background-position: center;
    background-repeat: no-repeat;
    background-size: 40%;
  }
</style>
<body class="um-vp " ontouchstart style="background:#FFFFFF">
  <div id="page_0" class="up ub ub-ver" tabindex="0">
    <!--header开始-->
    <header id="header" class="ub-ver">
      <div style="background-color:#3e454f;" class="cwhite uh bc-text-head ub 

bc-head">
        <div class="nav-btn cwhite back" id="nav-left"></div>
        <h1 class="ut ub-f1 ulev-3 ut-s tx-c" tabindex="0">customer价值排序

</h1>
        <div class="nav-btn nav-bt cwhite" id="nav-right">刷新</div>
      </div>
    </header>
    <!--header结束-->
    <!--content开始-->
    <div id="psgContent" class="ub-f1 tx-l" >
    </div>
    <!--content结束-->
    <div class="myfooter">
       <ul id="tab" class="ub">
        <!-- <li class="tabItem ub-f1 lh20 tx-c ub ub-ac ub-pc">旅客升舱</li>
        <li style="border-bottom:none" class="tabItem ub-f1 lh20 tx-c ub ub-

ac ub-pc">旅客降舱</li>
         <li class="tabItem ub-f1 lh20 tx-c ub ub-ac ub-pc">志愿者选择</li>
          <li class="tabItem ub-f1 lh20 tx-c ub ub-ac ub-pc">旅客候补</li> 
-->
      </ul>
    </div>
  </div>
  <script src="js/appcan.js"></script>
  <script src="js/appcan.control.js"></script>
  <script src="js/zy_control.js"></script>
  <script src="js/zy_click.js"></script>
  <script src="js/main.js"></script>
  <script src="js/candidate.js"></script>
  <script src="js/talkingdata.js"></script>
</body>
<script>
  appcan.ready(function(){
    appcan.button("#nav-left", "btn-act", function(){
      uexWidget.finishWidget('');
    });
    uexWindow.setReportKey(0,1);
            uexWindow.onKeyPressed = function(keyCode){
                if(keyCode==0){
                       uexWindow.setOrientation(1);  
                           uexWidget.finishWidget('');
                }
            }
    function back(){
      uexWidget.finishWidget('');
    }
    //var loginName=localStorage['MU30-lOGIN-USRNAME'];//获取登入的工号
   
    var loginName=appcan.locStorage.getVal("loginName");
    login(loginName);
  
  });
  var pages=[];//页面一个数组 
  var arr2=[];
  //页面权限验证的函数方法
  function login(loginName){
    appcan.window.openToast("正在加载页面,请稍后...","",5,1);
    var url="http://mpservice.ceair.com/mpservice/login_mpservice.action?loginName="+loginName;
    $.ajax({
      url:url,
      type:"GET",
      data:"",
      dataType:"JSON",
      success:function(data){
        console.log(data);
        appcan.window.closeToast();
        //console.log(data);
        var res=(JSON.parse(data));
        //console.log(res);
        var AppRole=(res.array.AppRole);
        if(AppRole==undefined||AppRole=="undefined"){
          appcan.window.alert("提示","非常抱歉,您没有访问权限","确定",function(){
            uexWidget.finishWidget('');
            return false;
          })
        }//此处判断 仅测试添加使用  实际情况不需要   用户登入成功以后 该接口都会返回这个属性
        //console.log(AppRole);
        var arr=AppRole.split(",");
        //console.log(arr);
        for(var i =0;i<arr.length;i++){
          if(arr[i]=="16"){
            arr2.push(arr[i]);
          }
          if(arr[i]=="20"){
             arr2.push(arr[i]);
          }
          if(arr[i]=="19"){
            arr2.push(arr[i]);
          }
          if(arr[i]=="15"){
            arr2.push(arr[i]);
          }
        }
        if(arr2.length==0){
          appcan.window.alert("提示","非常抱歉,您没有访问权限","确定",function(){
              uexWidget.finishWidget('');
          });
        }
        var content={};
        var li='';
        var tips1;//定义一个标题
        var tips2;//定义一个页面
        for(var z=0;z<arr2.length;z++){
          if(arr2[z]=="16"){
            var obj={
                  "inPageName": "candidateInput",
                  "inUrl": "candidateInput_content.html",
                  }; 
             li+=' <li class="tabItem ub-f1 lh20 tx-c ub ub-ac ub-pc" AppRole='+arr2[z]+'>旅客候补</li>';
             tips1="旅客候补";
             tips2="候补列表"
            pages.push(obj);  
          }
          if(arr2[z]=="15"){
            var obj={
                  "inPageName": "candidateUpgrade",
                  "inUrl": "candidateUpgrade_content.html",
                  };
             li+=' <li class="tabItem ub-f1 lh20 tx-c ub ub-ac ub-pc" AppRole='+arr2[z]+'>旅客升舱</li>'; 
             tips1="旅客升舱";
             tips2="刷新"        
            pages.push(obj); 
          }
          if(arr2[z]=="19"){
            var obj={
                  "inPageName": "volunteer",
                  "inUrl": "volunteer_content.html",
                  };
              li+='<li class="tabItem ub-f1 lh20 tx-c ub ub-ac ub-pc" AppRole='+arr2[z]+'>志愿者选择</li>';
              tips1="志愿者选择";
             tips2="刷新"    
            pages.push(obj);      
          }
          if(arr2[z]=="20"){
            var obj={
                    "inPageName": "candidateDowngrades",
                    "inUrl": "candidateDowngrades_content.html",
                  };

            li+=' <li style="border-bottom:none" class="tabItem ub-f1 lh20 tx-c ub ub-ac ub-pc" AppRole='+arr2[z]+'>旅客降舱</li>';  
            tips1="旅客降舱";
            tips2="刷新"    
            pages.push(obj);      
          }
        }
        if(arr2.length==1){
           $("#tab").css({
            "display":"none",
            "box-shadow":"none"
           });
           $("h1").text(tips1);
           $("#nav-right").text(tips2);

        }else{
           $("#tab").html(li);
           $("#tab").css({
              "box-shadow":"0px 2px 2px 3px #f5f5f5 inset",
             " width": "100%",
              "height": "2.5em",
              "margin": "0 auto",
              "margin-top": ".5em",
            /*  border-radius: .4em;*/
              "overflow": "hidden",
           });
            $("#tab li").eq(0).css({
              "border-top":"2px solid orange",
              // "background": "rgb(13, 103, 237)",
              "color": "orange",
              "border-radius": ".2em"
            })
        }
        var titHeight = $$('header').offsetHeight;
        // localStorage.setItem("titHeight", titHeight);
        inPageName =pages[0].inPageName;//定义一个初始的值
        if(inPageName=="candidateInput"){
           $("#nav-right").text("候补列表");
              $("#nav-right").css("padding","0 .4em");
            }else{
               $("#nav-right").text("刷新");
               $("#nav-right").css("padding","0");
        }
        var AppRole;//页面权限编号   候补旅客查看15    旅客升舱16  志愿者选择19 旅客降舱20
        appcan.frame.open({
          id: "psgContent",
          url: pages,
          top: titHeight,
          left: 0,
          index:0,
          change: function(err, res){
            //浮动窗口推拽变更时回调，可控制tab进行同步变更
            var index = Number(res.multiPopSelectedIndex);//页面tab 不固定  这里的索引判断不适合用
            var AppRole=$("#tab li").eq(index).attr("AppRole");//获取当前滑动tab的自定义属性  这个是固定
            if (AppRole == "16"){
              inPageName = 'candidateInput';
              $("#nav-right").text("候补列表");
              $("#nav-right").css("padding","0 .4em");
            } else if (AppRole == "15") {
              inPageName = 'candidateUpgrade';
            }else if(AppRole=="19"){
               inPageName = 'volunteer';
            }else if(AppRole=="20"){
               inPageName = 'candidateDowngrades';
            }
            if(AppRole !="16"){
              $("#nav-right").text("刷新");
               $("#nav-right").css("padding","0");
            }
            var tabItem = $(".tabItem");
             for (var i = 0; i<=3; i++){
              $(tabItem[i]).css({
                "border-top":"none",
                // "background": "rgba(209, 203, 209, 0.53)",
                "color": "black",
                "border-radius": "0em"
              });
            }
            $(tabItem[index]).css({
              "border-top":"2px solid orange",
              // "background": "rgb(13, 103, 237)",
              "color": "orange",
              "border-radius": ".2em"
            });
          }
        });
        var tabItem = $(".tabItem");
        for (var a = 0; a < tabItem.length; a++){
          tabItem[a].index = a;
          $(tabItem[a]).click(function(ev){
          var AppRole=$(this).attr("AppRole");
            for (var i = 0; i < tabItem.length; i++){
              $(tabItem[i]).css({
                "border-top":"none",
                // "background": "rgba(209, 203, 209, 0.53)",
                "color": "black",
                "border-radius": "0em"
              });
            }
            if (AppRole =="16"){
              inPageName = 'candidateInput';
              //alert(inPageName);
            }
            else if (AppRole=="15"){
              inPageName = 'candidateUpgrade';
              //alert(inPageName);
            }else if(AppRole=="19"){
               inPageName = 'volunteer';
               //alert(inPageName);
            }else if(AppRole=="20"){
              inPageName="candidateDowngrades";
              //alert(inPageName);
            }
            if(inPageName=="candidateInput"){ 
               $("#nav-right").text("候补列表");
               $("#nav-right").css("padding","0 .4em");
            }else{
              $("#nav-right").text("刷新");
              $("#nav-right").css("padding","0");
            }
            $(tabItem[this.index]).css({
              "border-top":"2px solid orange",
              // "background": "rgb(13, 103, 237)",
              "color": "orange",
              "border-radius": ".2em"
            });
              appcan.frame.selectMulti("psgContent",this.index);
          });
        }
      },
      error:function(){
        appcan.window.alert("提示","服务器无法响应,请稍后再试...","确定");
        appcan.window.closeToast();
        return false;
      }
    })
  }
  appcan.button("#nav-right", "btn-act", function(){
           uexWindow.evaluateMultiPopoverScript("passengerServicePage", "psgContent", inPageName, "CandidateUpgrade()");  
            
  });
</script>

</html>
